package gentle.support.duplicateSubmission;

import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
//import com.fastaccess.permission.base.PermissionHelper;

/**
 * @author:wwz
 */
@Aspect
@Component
public class LogProxy {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Pointcut("@annotation(gentle.support.duplicateSubmission.Resubmit)")
    public void beforpointcut() {
    }

    private final static class Holder {
        private static HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
    }

    @Before("beforpointcut()&& @annotation(resubmit)")
    public void beforMethod(Resubmit resubmit) throws Throwable {
        try {
            logger.error("重复提交【代码未执行】");
            System.out.println("重复提交【代码未执行】");
        } finally {
        }
    }
}